﻿using Comsenz.Base.Exceptions;
using System;
namespace Comsenz.Base
{
    /// <summary>
    /// 异常处理器
    /// </summary>
    /// <author>Chiron</author>
    public static class ExceptionHandler
    {
        /// <summary>
        /// 处理异常
        /// </summary>
        /// <param name="data">源数据</param>
        public static string Handle(string data)
        {
            switch ((data ?? string.Empty).ToLower())
            {
                case "invalid request":
                    throw new InvalidRequestException();
                case "access denied":
                    throw new AccessDeniedException();
                case "unauthorized access":
                    throw new AccessDeniedException("未授权的访问");
                case "authracation has expiried":
                    throw new AuthracationExpiriedException();
                case "module not found!":
                    throw new InvalidOperationException("请求的模块是无效的!");
                case "action not found!":
                    throw new InvalidOperationException("请求的操作是无效的!");
            }
            return data;
        }
    }
}
